﻿using BCCommon;
using BCCommon.Enums;
using BCCommon.TMS.Order;
using BCDto.Sim.Admin.Admin;
using BCDto.TMS.Driver;
using BCDto.TMS.Order;
using BCDto.TMS.Order.OrderPool;
using System;

namespace BCService.TMS.Order
{
    /// <summary>
    /// 订单池
    /// </summary>
    public interface IOrderPoolService
    {
        /// <summary>
        /// 获取订单信息
        /// </summary>
        /// <param name="orderId">订单Id</param>
        /// <returns></returns>
        OrderPoolDto GetOrder(long orderId);
        /// <summary>
        /// 获取订单列表
        /// </summary>
        /// <param name="adminDto">管理员</param>
        /// <param name="provinceCode">省份编码</param>
        /// <param name="cityCode">市编码</param>
        /// <param name="countyCode">区县编码</param>
        /// <param name="handleStatus">指派处理状态</param>
        /// <param name="driverId">司机Id</param>
        /// <param name="start">开始时间</param>
        /// <param name="end">结束时间</param>
        /// <param name="ascending">升序</param>
        /// <param name="pageIndex">当前页码</param>
        /// <param name="pageSize">每页数据条数</param>
        /// <returns></returns>
        PageableList<OrderPoolDto> GetOrders(AdminDto adminDto, string provinceCode, string cityCode, string countyCode, OrderAssignHandleStatus? handleStatus, long? driverId, DateTime? start, DateTime? end, bool? ascending, int pageIndex, int pageSize);

        /// <summary>
        /// 指派车辆
        /// </summary>
        /// <param name="orderIds">订单Id</param>
        /// <param name="driverId">司机Id</param>
        /// <param name="distance">总距离</param>
        /// <param name="adminDto">指派人信息</param> 
        bool AssignVehicle(long[] orderIds, long driverId, int? distance, AdminDto adminDto);
        /// <summary>
        /// 指派车辆
        /// </summary>
        /// <param name="vehicleNo">车牌号</param>
        /// <param name="orderIds">订单Id</param>
        /// <param name="distance">总距离</param>
        /// <param name="adminDto">指派人信息</param> 
        bool AssignVehicle(string vehicleNo, long[] orderIds, int? distance, AdminDto adminDto);

        /// <summary>
        /// 指派超时后
        /// 清理订单指派信息
        /// </summary>
        /// <param name="orderId">订单Id</param>
        void ClearOrderAssign(long orderId);
        /// <summary>
        /// 忽略订单指派
        /// </summary>
        /// <param name="driverId">司机Id</param>
        /// <param name="orderId">订单Id</param>
        void IgnoreOrderAssign(long driverId, long orderId);
        /// <summary>
        /// 司机接单后
        /// 关闭订单在订单池的指派状态
        /// </summary>
        /// <param name="orderId">订单Id</param>
        void CloseOrder(long orderId);

        ///// <summary>
        ///// 是否拥有超级管理员角色
        ///// </summary>
        ///// <param name="adminId">管理员Id</param>
        ///// <returns></returns>
        //bool IsAdministratorRole(long adminId);

        ///// <summary>
        ///// 获取订单成交量的数据
        ///// </summary>
        ///// <param name="adminDto">管理员信息</param>
        ///// <param name="start">开始时间</param>
        ///// <param name="end">结束时间</param>
        ///// <param name="assignStatus">订单指派状态</param>
        ///// <param name="pageIndex">当前页码</param>
        ///// <param name="pageSize">每页数据条数</param>
        ///// <returns></returns>
        //PageableList<OrderPoolDto> GetOrderPoolStatistics(AdminDto adminDto, DateTime? start, DateTime? end, OrderAssignHandleStatus? assignStatus, int pageIndex, int pageSize);

        /// <summary>
        /// 获取指派订单列表
        /// </summary>
        /// <param name="processing">订单处理状态</param>
        /// <param name="driverId">司机Id</param>
        /// <param name="pageIndex">当前页码</param>
        /// <param name="pageSize">每页数据条数</param>
        /// <returns></returns>
        PageableList<OrderPoolDto> GetDriverOrders(OrderAssignHandleStatus? processing, long driverId, int pageIndex, int pageSize);
        /// <summary>
        /// 司机接指派订单
        /// </summary>
        /// <param name="driver">当前司机信息</param>
        /// <param name="orderId">订单Id</param>
        /// <returns></returns>
        OrderPoolDto ReceiveOrderAssign(DriverDto driver, long orderId);
    }
}
